package cn.itsource.controller;

import cn.itsource.basic.domain.AjaxResult;
import cn.itsource.basic.domain.PageList;
import cn.itsource.domain.org.Employee;
import cn.itsource.service.EmployeeService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("empl")
@RestController
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;

    @PostMapping("pageList")
    public AjaxResult<Employee> pageList(@RequestBody Employee employee){
        Page<Employee> page = new Page<>(1,10);
        EntityWrapper<Employee> wrapper = new EntityWrapper<>();
        wrapper.like("username",employee.getUsername());
        Page<Employee> employeePage = employeeService.selectPage(page, wrapper);
        PageList<Employee> pageList = new PageList<>();
        pageList.setList(employeePage.getRecords());
        pageList.setTotal(employeePage.getTotal());
        return AjaxResult.setResult(pageList);
        //return employeeService.pageList(employee);
    }
}
